package com.back.mapper;

import com.back.entity.Score;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface ScoreDao {
    // 对某个电影添加评分
    @Insert("insert into score(movie_id, user_id, score) values(#{movie_id}, #{user_id}, #{score})")
    void insertScore(@Param("movie_id") int movie_id,@Param("user_id")  int user_id,@Param("score")  int score);

    // 对某个电影修改评分
    @Insert("update score set score=#{score} where movie_id=#{movie_id} and user_id=#{user_id}")
    void updateScore(@Param("movie_id") int movie_id,@Param("user_id")  int user_id,@Param("score")  int score);

    // 获取某个电影某个用户的评分
    @Select("select * from score where movie_id=#{movie_id} and user_id=#{user_id}")
    Score selectScoreByMovieIdAndUserId(@Param("movie_id") int movie_id,@Param("user_id")  int user_id);
}
